export enum ButtonActions {
    EXIT = "onExit",
    OK = "onOK",
    OPEN_INTERNAL = "onOpenInternal",
    OPEN_EXTERNAL = "onOpenExternal",
    CANCEL = "onCancel",
    RESUME = "onResume",
    CONTINUE = "onContinue",
}

// 显示的属性定义
export interface GeneralErrorSheetProps_Explict {
    [ButtonActions.EXIT]?: () => void;
    [ButtonActions.OK]?: () => void;
    [ButtonActions.CANCEL]?: () => void;
    [ButtonActions.RESUME]?: () => void;
    [ButtonActions.CONTINUE]?: () => void;
    [ButtonActions.OPEN_INTERNAL]?: () => void;
    [ButtonActions.OPEN_EXTERNAL]?: () => void;
    type: string;
    isOpen: boolean;
    travelDocument?: string;
}



// ------------ 隐式的属性定义

// 步骤1:  获取所有按钮动作的枚举值联合类型
/** 
 * typeof ButtonActions 得到枚举值的联合类型
    type ButtonActionsType = {
        EXIT: "onExit";
        OK: "onOK";
        OPEN_INTERNAL: "onOpenInternal";
        // ...其他键值对
    };
 */

/**
 * keyof typeof ButtonActions 得到 KEY
 * type Result = "EXIT" | "OK" | "OPEN_INTERNAL" | "OPEN_EXTERNAL" | "CANCEL" | "RESUME" | "CONTINUE";
 */
type ButtonActionKeys = keyof typeof ButtonActions;

/**
 * typeof ButtonActions[ButtonActionKeys]: 得到 values
 * "onExit" | "onOK" | "onOpenInternal" | "onOpenExternal" | "onCancel" | "onResume" | "onContinue"
 */
type ButtonActionValues = typeof ButtonActions[ButtonActionKeys]; // 得到 "onExit" | "onOK" | ... 的联合类型

// 步骤2: 创建映射类型, 动态生成按钮动作属性
/**
 * K in ButtonActionKeys 得到的是:
 *  "onExit":() => void | "onOK":() => void |
 *  "onOpenInternal":() => void | "onOpenExternal":() => void |
 *  "onCancel":() => void | "onResume":() => void | "onContinue"
 */
type ErrorSheetButtonActionProps = {
    [K in ButtonActionKeys]?: () => void; // 所有属性均为可选函数
};


interface GeneralErrorSheetProps_Hint extends ErrorSheetButtonActionProps {
    type: string;
    isOpen: boolean;
    travelDocument?: string;
}